#include "addWordDialog.h"

addWordDialog::addWordDialog(QWidget *parent) : QDialog(parent), ui(new Ui::addWordDialog) {
	ui->setupUi(this);
	connect(ui->okButton, SIGNAL(clicked()), this, SLOT(addingDone()));
	connect(ui->stopButton, SIGNAL(clicked()), this, SLOT(reject()));
	ui->tableWidget->installEventFilter(this);
}
addWordDialog::~addWordDialog()
{
	delete ui;
}
void addWordDialog::on_addButton_clicked() {
	ui->tableWidget->setRowCount(ui->tableWidget->rowCount() + 1);
}
void addWordDialog::on_removeButton_clicked()
{
	ui->tableWidget->removeRow(ui->tableWidget->rowCount() - 1);
	//ui->tableWidget->setRowCount(ui->tableWidget->rowCount() + 1);
}
void addWordDialog::addingDone()
{
	emit accepted(wordList());
	ui->tableWidget->clear();
	ui->tableWidget->setHorizontalHeaderItem(0, new QTableWidgetItem(tr("Слово")));
	ui->tableWidget->setHorizontalHeaderItem(1, new QTableWidgetItem(tr("Транскрипция")));
	ui->tableWidget->setHorizontalHeaderItem(2, new QTableWidgetItem(tr("Перевод")));
	accept();
}
